import QMFetch from 'api/index';
class WebApi{
    
    /**
     * 获取售后订单详细信息
     * @param rid 服务单编号
     */
    fetchOrder = (rid) => {
        return QMFetch({
            url: `afterSale/detail/${rid}`,
            method:"POST",
            body:{}
        })
    }

    /**
     * 审核售后订单
     * @param {id } 服务单编号
     * @param {* boolean} checkout 
     */
    auditAfterSaleOrder = (id,checkout) => {
        return QMFetch({
            url:`afterSale/audit/${id}/${checkout}`,
            method:"POST",
            body:{}
        })
    }
    /**
     * 取消售后申请，关闭订单
     * @param { id } 服务单编号 
     */
    cancelAfterSaleOrder = ( id ) => {
        return QMFetch({
            url:`afterSale/cancel/${id}`,
            method:"POST",
            body:{}
        })
    }

    /**
     * 签收退货 
     * @param {string} id 服务单编号
     */
    receivedGoods = (id) => {
        return QMFetch({
            url:`afterSale/receiveGoods/${id}`,
            method:"POST",
            body:{}
        })
    }

    /**
     * 退款时，需要查询实际可退金额，和相应订单信息
     * @param {string } id 服务单编号
     */
    fetchRefundOrderInfo = (id) => {
        return QMFetch({
            url:`afterSale/refund/${id}`,
            method:"POST",
            body:{}
        })
    }

    confirmRefund = (refund) => {
        return QMFetch({
            url:'afterSale/refund',
            method:"POST",
            body:refund
        })
    }

    /**
     * 查询卖家留言
     * @param {string } id 服务单编号 
     */
    fetchSellerMsg = (id) => {
        return QMFetch({
            url:`afterSale/sellerMsg/${id}`,
            method:"POST",
            body:{}
        })
    }

    /**
     * 添加卖家留言
     * @param {<object>(tid:"",applyId:"",message) } sellerMsg 服务单编号 
     */
    appendSellerMsg = (sellerMsg) => {
        return QMFetch({
            url:'afterSale/addSellerMsg',
            method:"POST",
            body:sellerMsg
        })
    }
}

export default new WebApi;